package f_facade.b_design_pattern;

/**
 * Created by wug on 2016/7/1 0001.
 */
public class CarAirCondition extends AirCondition implements AirConditionFuc {

    public CarAirCondition() {
        name = "汽车空调";
    }

    @Override
    public void refrigeration() {
        if (!electricity.isOn()){
            return;
        }
        System.out.println(name + "正在制冷中");
    }

    @Override
    public void heating() {
        if (!electricity.isOn()){
            return;
        }
        System.out.println(name + "正在制热中");
    }

    @Override
    public void detectRoomTemp(int temp) {
        if (!electricity.isOn()){
            return;
        }
        super.toomTemp = temp;
    }

    @Override
    public void adjustTemp(int targetTemp) {
        if (!electricity.isOn()){
            return;
        }
        super.targetTemp = targetTemp;
    }

    @Override
    public void run() {
        if (!electricity.isOn()){
            return;
        }
        if (toomTemp > targetTemp) {
            refrigeration();
        } else {
            heating();
        }
    }
}
